<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OptionParser - optparse: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-OptionParser-label-OptionParser">OptionParser</a>
    <li><a href="#class-OptionParser-label-New+to+OptionParser-3F">New to <code>OptionParser</code>?</a>
    <li><a href="#class-OptionParser-label-Introduction">Introduction</a>
    <li><a href="#class-OptionParser-label-Features">Features</a>
    <li><a href="#class-OptionParser-label-Minimal+example">Minimal example</a>
    <li><a href="#class-OptionParser-label-Generating+Help">Generating Help</a>
    <li><a href="#class-OptionParser-label-Required+Arguments">Required Arguments</a>
    <li><a href="#class-OptionParser-label-Type+Coercion">Type Coercion</a>
    <li><a href="#class-OptionParser-label-Using+Built-in+Conversions">Using Built-in Conversions</a>
    <li><a href="#class-OptionParser-label-Creating+Custom+Conversions">Creating Custom Conversions</a>
    <li><a href="#class-OptionParser-label-Store+options+to+a+Hash">Store options to a Hash</a>
    <li><a href="#class-OptionParser-label-Complete+example">Complete example</a>
    <li><a href="#class-OptionParser-label-Shell+Completion">Shell Completion</a>
    <li><a href="#class-OptionParser-label-Further+documentation">Further documentation</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-accept">::accept</a>
    <li ><a href="#method-c-each_const">::each_const</a>
    <li ><a href="#method-c-getopts">::getopts</a>
    <li ><a href="#method-c-inc">::inc</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-reject">::reject</a>
    <li ><a href="#method-c-search_const">::search_const</a>
    <li ><a href="#method-c-show_version">::show_version</a>
    <li ><a href="#method-c-terminate">::terminate</a>
    <li ><a href="#method-c-top">::top</a>
    <li ><a href="#method-c-with">::with</a>
    <li class="calls-super" ><a href="#method-i-abort">#abort</a>
    <li ><a href="#method-i-accept">#accept</a>
    <li ><a href="#method-i-additional_message">#additional_message</a>
    <li ><a href="#method-i-banner">#banner</a>
    <li ><a href="#method-i-base">#base</a>
    <li ><a href="#method-i-candidate">#candidate</a>
    <li ><a href="#method-i-def_head_option">#def_head_option</a>
    <li ><a href="#method-i-def_option">#def_option</a>
    <li ><a href="#method-i-def_tail_option">#def_tail_option</a>
    <li ><a href="#method-i-define">#define</a>
    <li ><a href="#method-i-define_by_keywords">#define_by_keywords</a>
    <li ><a href="#method-i-define_head">#define_head</a>
    <li ><a href="#method-i-define_tail">#define_tail</a>
    <li ><a href="#method-i-environment">#environment</a>
    <li ><a href="#method-i-getopts">#getopts</a>
    <li ><a href="#method-i-help">#help</a>
    <li ><a href="#method-i-inc">#inc</a>
    <li ><a href="#method-i-load">#load</a>
    <li ><a href="#method-i-make_switch">#make_switch</a>
    <li ><a href="#method-i-new">#new</a>
    <li ><a href="#method-i-on">#on</a>
    <li ><a href="#method-i-on_head">#on_head</a>
    <li ><a href="#method-i-on_tail">#on_tail</a>
    <li ><a href="#method-i-order">#order</a>
    <li ><a href="#method-i-order-21">#order!</a>
    <li ><a href="#method-i-parse">#parse</a>
    <li ><a href="#method-i-parse-21">#parse!</a>
    <li ><a href="#method-i-permute">#permute</a>
    <li ><a href="#method-i-permute-21">#permute!</a>
    <li ><a href="#method-i-program_name">#program_name</a>
    <li ><a href="#method-i-reject">#reject</a>
    <li ><a href="#method-i-release">#release</a>
    <li ><a href="#method-i-remove">#remove</a>
    <li ><a href="#method-i-separator">#separator</a>
    <li ><a href="#method-i-summarize">#summarize</a>
    <li ><a href="#method-i-terminate">#terminate</a>
    <li ><a href="#method-i-to_a">#to_a</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-top">#top</a>
    <li ><a href="#method-i-ver">#ver</a>
    <li ><a href="#method-i-version">#version</a>
    <li class="calls-super" ><a href="#method-i-warn">#warn</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OptionParser">
    <h1 id="class-OptionParser" class="class">
      class OptionParser
    </h1>

    <section class="description">
    
<h2 id="class-OptionParser-label-OptionParser"><a href="OptionParser.html"><code>OptionParser</code></a><span><a href="#class-OptionParser-label-OptionParser">&para;</a> <a href="#top">&uarr;</a></span></h2>

<h3 id="class-OptionParser-label-New+to+OptionParser-3F">New to <code>OptionParser</code>?<span><a href="#class-OptionParser-label-New+to+OptionParser-3F">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>See the <a href="optparse/tutorial_rdoc.html">Tutorial</a>.</p>

<h3 id="class-OptionParser-label-Introduction">Introduction<span><a href="#class-OptionParser-label-Introduction">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="OptionParser.html"><code>OptionParser</code></a> is a class for command-line option analysis.  It is much more advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented solution.</p>

<h3 id="class-OptionParser-label-Features">Features<span><a href="#class-OptionParser-label-Features">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ol><li>
<p>The argument specification and the code to handle it are written in the same place.</p>
</li><li>
<p>It can output an option summary; you don’t need to maintain this string separately.</p>
</li><li>
<p>Optional and mandatory arguments are specified very gracefully.</p>
</li><li>
<p>Arguments can be automatically converted to a specified class.</p>
</li><li>
<p>Arguments can be restricted to a certain set.</p>
</li></ol>

<p>All of these features are demonstrated in the examples below.  See <a href="OptionParser.html#method-i-make_switch"><code>make_switch</code></a> for full documentation.</p>

<h3 id="class-OptionParser-label-Minimal+example">Minimal example<span><a href="#class-OptionParser-label-Minimal+example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>

<span class="ruby-identifier">options</span> = {}
<span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-string">&quot;Usage: example.rb [options]&quot;</span>

  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-v&quot;</span>, <span class="ruby-string">&quot;--[no-]verbose&quot;</span>, <span class="ruby-string">&quot;Run verbosely&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:verbose</span>] = <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>

<span class="ruby-identifier">p</span> <span class="ruby-identifier">options</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">ARGV</span>
</pre>

<h3 id="class-OptionParser-label-Generating+Help">Generating Help<span><a href="#class-OptionParser-label-Generating+Help">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="OptionParser.html"><code>OptionParser</code></a> can be used to automatically generate help for the commands you write:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>

<span class="ruby-constant">Options</span> = <span class="ruby-constant">Struct</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:name</span>)

<span class="ruby-keyword">class</span> <span class="ruby-constant">Parser</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse</span>(<span class="ruby-identifier">options</span>)
    <span class="ruby-identifier">args</span> = <span class="ruby-constant">Options</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;world&quot;</span>)

    <span class="ruby-identifier">opt_parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-string">&quot;Usage: example.rb [options]&quot;</span>

      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-nNAME&quot;</span>, <span class="ruby-string">&quot;--name=NAME&quot;</span>, <span class="ruby-string">&quot;Name to say hello to&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">args</span>.<span class="ruby-identifier">name</span> = <span class="ruby-identifier">n</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-h&quot;</span>, <span class="ruby-string">&quot;--help&quot;</span>, <span class="ruby-string">&quot;Prints this help&quot;</span>) <span class="ruby-keyword">do</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-identifier">parser</span>
        <span class="ruby-identifier">exit</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">opt_parser</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">options</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">args</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">options</span> = <span class="ruby-constant">Parser</span>.<span class="ruby-identifier">parse</span> <span class="ruby-node">%w[--help]</span>

<span class="ruby-comment">#=&gt;</span>
   <span class="ruby-comment"># Usage: example.rb [options]</span>
   <span class="ruby-comment">#     -n, --name=NAME                  Name to say hello to</span>
   <span class="ruby-comment">#     -h, --help                       Prints this help</span>
</pre>

<h3 id="class-OptionParser-label-Required+Arguments">Required Arguments<span><a href="#class-OptionParser-label-Required+Arguments">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>For options that require an argument, option specification strings may include an option name in all caps. If an option is used without the required argument, an exception will be raised.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>

<span class="ruby-identifier">options</span> = {}
<span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-r&quot;</span>, <span class="ruby-string">&quot;--require LIBRARY&quot;</span>,
            <span class="ruby-string">&quot;Require the LIBRARY before executing your script&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;You required #{lib}!&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>
</pre>

<p>Used:</p>

<pre>$ ruby optparse-test.rb -r
optparse-test.rb:9:in `&lt;main&gt;&#39;: missing argument: -r (OptionParser::MissingArgument)
$ ruby optparse-test.rb -r my-library
You required my-library!</pre>

<h3 id="class-OptionParser-label-Type+Coercion">Type Coercion<span><a href="#class-OptionParser-label-Type+Coercion">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="OptionParser.html"><code>OptionParser</code></a> supports the ability to coerce command line arguments into objects for us.</p>

<p><a href="OptionParser.html"><code>OptionParser</code></a> comes with a few ready-to-use kinds of type coercion. They are:</p>
<ul><li>
<p>Date  – Anything accepted by <code>Date.parse</code> (need to require <code>optparse/date</code>)</p>
</li><li>
<p>DateTime – Anything accepted by <code>DateTime.parse</code> (need to require <code>optparse/date</code>)</p>
</li><li>
<p>Time – Anything accepted by <code>Time.httpdate</code> or <code>Time.parse</code> (need to require <code>optparse/time</code>)</p>
</li><li>
<p>URI  – Anything accepted by <code>URI.parse</code> (need to require <code>optparse/uri</code>)</p>
</li><li>
<p>Shellwords – Anything accepted by <code>Shellwords.shellwords</code> (need to require <code>optparse/shellwords</code>)</p>
</li><li>
<p>String – Any non-empty string</p>
</li><li>
<p>Integer – Any integer. Will convert octal. (e.g. 124, -3, 040)</p>
</li><li>
<p>Float – Any float. (e.g. 10, 3.14, -100E+13)</p>
</li><li>
<p>Numeric – Any integer, float, or rational (1, 3.4, 1/3)</p>
</li><li>
<p><a href="OptionParser.html#DecimalInteger"><code>DecimalInteger</code></a> – Like <code>Integer</code>, but no octal format.</p>
</li><li>
<p><a href="OptionParser.html#OctalInteger"><code>OctalInteger</code></a> – Like <code>Integer</code>, but no decimal format.</p>
</li><li>
<p><a href="OptionParser.html#DecimalNumeric"><code>DecimalNumeric</code></a> – Decimal integer or float.</p>
</li><li>
<p>TrueClass –  Accepts ‘+, yes, true, -, no, false’ and defaults as <code>true</code></p>
</li><li>
<p>FalseClass – Same as <code>TrueClass</code>, but defaults to <code>false</code></p>
</li><li>
<p>Array – Strings separated by ‘,’ (e.g. 1,2,3)</p>
</li><li>
<p>Regexp – Regular expressions. Also includes options.</p>
</li></ul>

<p>We can also add our own coercions, which we will cover below.</p>

<h4 id="class-OptionParser-label-Using+Built-in+Conversions">Using Built-in Conversions<span><a href="#class-OptionParser-label-Using+Built-in+Conversions">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>As an example, the built-in <code>Time</code> conversion is used. The other built-in conversions behave in the same way. <a href="OptionParser.html"><code>OptionParser</code></a> will attempt to parse the argument as a <code>Time</code>. If it succeeds, that time will be passed to the handler block. Otherwise, an exception will be raised.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse/time&#39;</span>
<span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-t&quot;</span>, <span class="ruby-string">&quot;--time [TIME]&quot;</span>, <span class="ruby-constant">Time</span>, <span class="ruby-string">&quot;Begin execution at given time&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">p</span> <span class="ruby-identifier">time</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>
</pre>

<p>Used:</p>

<pre>$ ruby optparse-test.rb  -t nonsense
... invalid argument: -t nonsense (OptionParser::InvalidArgument)
$ ruby optparse-test.rb  -t 10-11-12
2010-11-12 00:00:00 -0500
$ ruby optparse-test.rb  -t 9:30
2014-08-13 09:30:00 -0400</pre>

<h4 id="class-OptionParser-label-Creating+Custom+Conversions">Creating Custom Conversions<span><a href="#class-OptionParser-label-Creating+Custom+Conversions">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>The <code>accept</code> method on <a href="OptionParser.html"><code>OptionParser</code></a> may be used to create converters. It specifies which conversion block to call whenever a class is specified. The example below uses it to fetch a <code>User</code> object before the <code>on</code> handler receives it.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>

<span class="ruby-constant">User</span> = <span class="ruby-constant">Struct</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:id</span>, <span class="ruby-value">:name</span>)

<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_user</span> <span class="ruby-identifier">id</span>
  <span class="ruby-identifier">not_found</span> = <span class="ruby-operator">-&gt;</span>{ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;No User Found for id #{id}&quot;</span> }
  [ <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>, <span class="ruby-string">&quot;Sam&quot;</span>),
    <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2</span>, <span class="ruby-string">&quot;Gandalf&quot;</span>) ].<span class="ruby-identifier">find</span>(<span class="ruby-identifier">not_found</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">u</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">op</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">op</span>.<span class="ruby-identifier">accept</span>(<span class="ruby-constant">User</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user_id</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">find_user</span> <span class="ruby-identifier">user_id</span>.<span class="ruby-identifier">to_i</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">op</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--user ID&quot;</span>, <span class="ruby-constant">User</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">user</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-identifier">user</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">op</span>.<span class="ruby-identifier">parse!</span>
</pre>

<p>Used:</p>

<pre>$ ruby optparse-test.rb --user 1
#&lt;struct User id=1, name=&quot;Sam&quot;&gt;
$ ruby optparse-test.rb --user 2
#&lt;struct User id=2, name=&quot;Gandalf&quot;&gt;
$ ruby optparse-test.rb --user 3
optparse-test.rb:15:in `block in find_user&#39;: No User Found for id 3 (RuntimeError)</pre>

<h3 id="class-OptionParser-label-Store+options+to+a+Hash">Store options to a Hash<span><a href="#class-OptionParser-label-Store+options+to+a+Hash">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The <code>into</code> option of <code>order</code>, <code>parse</code> and so on methods stores command line options into a Hash.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>

<span class="ruby-identifier">options</span> = {}
<span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;-a&#39;</span>)
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;-b NUM&#39;</span>, <span class="ruby-constant">Integer</span>)
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;-v&#39;</span>, <span class="ruby-string">&#39;--verbose&#39;</span>)
<span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-value">into:</span> <span class="ruby-identifier">options</span>)

<span class="ruby-identifier">p</span> <span class="ruby-identifier">options</span>
</pre>

<p>Used:</p>

<pre>$ ruby optparse-test.rb -a
{:a=&gt;true}
$ ruby optparse-test.rb -a -v
{:a=&gt;true, :verbose=&gt;true}
$ ruby optparse-test.rb -a -b 100
{:a=&gt;true, :b=&gt;100}</pre>

<h3 id="class-OptionParser-label-Complete+example">Complete example<span><a href="#class-OptionParser-label-Complete+example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The following example is a complete Ruby program.  You can run it and see the effect of specifying various options.  This is probably the best way to learn the features of <code>optparse</code>.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;optparse/time&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ostruct&#39;</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">&#39;pp&#39;</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">OptparseExample</span>
  <span class="ruby-constant">Version</span> = <span class="ruby-string">&#39;1.0.0&#39;</span>

  <span class="ruby-constant">CODES</span> = <span class="ruby-node">%w[iso-2022-jp shift_jis euc-jp utf8 binary]</span>
  <span class="ruby-constant">CODE_ALIASES</span> = { <span class="ruby-string">&quot;jis&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;iso-2022-jp&quot;</span>, <span class="ruby-string">&quot;sjis&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;shift_jis&quot;</span> }

  <span class="ruby-keyword">class</span> <span class="ruby-constant">ScriptOptions</span>
    <span class="ruby-identifier">attr_accessor</span> <span class="ruby-value">:library</span>, <span class="ruby-value">:inplace</span>, <span class="ruby-value">:encoding</span>, <span class="ruby-value">:transfer_type</span>,
                  <span class="ruby-value">:verbose</span>, <span class="ruby-value">:extension</span>, <span class="ruby-value">:delay</span>, <span class="ruby-value">:time</span>, <span class="ruby-value">:record_separator</span>,
                  <span class="ruby-value">:list</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">library</span> = []
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">inplace</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-string">&quot;utf8&quot;</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">transfer_type</span> = <span class="ruby-value">:auto</span>
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">verbose</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_options</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-string">&quot;Usage: example.rb [options]&quot;</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">&quot;&quot;</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">&quot;Specific options:&quot;</span>

      <span class="ruby-comment"># add additional options</span>
      <span class="ruby-identifier">perform_inplace_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">delay_execution_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">execute_at_time_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">specify_record_separator_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">list_example_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">specify_encoding_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">optional_option_argument_with_keyword_completion_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">boolean_verbose_option</span>(<span class="ruby-identifier">parser</span>)

      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">&quot;&quot;</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">&quot;Common options:&quot;</span>
      <span class="ruby-comment"># No argument, shows at tail.  This will print an options summary.</span>
      <span class="ruby-comment"># Try it and see!</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-string">&quot;-h&quot;</span>, <span class="ruby-string">&quot;--help&quot;</span>, <span class="ruby-string">&quot;Show this message&quot;</span>) <span class="ruby-keyword">do</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-identifier">parser</span>
        <span class="ruby-identifier">exit</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-comment"># Another typical switch to print the version.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-string">&quot;--version&quot;</span>, <span class="ruby-string">&quot;Show version&quot;</span>) <span class="ruby-keyword">do</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-constant">Version</span>
        <span class="ruby-identifier">exit</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">perform_inplace_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Specifies an optional option argument</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-i&quot;</span>, <span class="ruby-string">&quot;--inplace [EXTENSION]&quot;</span>,
                <span class="ruby-string">&quot;Edit ARGV files in place&quot;</span>,
                <span class="ruby-string">&quot;(make backup if EXTENSION supplied)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ext</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">inplace</span> = <span class="ruby-keyword">true</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">extension</span> = <span class="ruby-identifier">ext</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;&#39;</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">extension</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/\A\.?(?=.)/</span>, <span class="ruby-string">&quot;.&quot;</span>)  <span class="ruby-comment"># Ensure extension begins with dot.</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delay_execution_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Cast &#39;delay&#39; argument to a Float.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--delay N&quot;</span>, <span class="ruby-constant">Float</span>, <span class="ruby-string">&quot;Delay N seconds before executing&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">delay</span> = <span class="ruby-identifier">n</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">execute_at_time_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Cast &#39;time&#39; argument to a Time object.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-t&quot;</span>, <span class="ruby-string">&quot;--time [TIME]&quot;</span>, <span class="ruby-constant">Time</span>, <span class="ruby-string">&quot;Begin execution at given time&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">time</span> = <span class="ruby-identifier">time</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">specify_record_separator_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Cast to octal integer.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-F&quot;</span>, <span class="ruby-string">&quot;--irs [OCTAL]&quot;</span>, <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">OctalInteger</span>,
                <span class="ruby-string">&quot;Specify record separator (default \\0)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rs</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">record_separator</span> = <span class="ruby-identifier">rs</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">list_example_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># List of arguments.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--list x,y,z&quot;</span>, <span class="ruby-constant">Array</span>, <span class="ruby-string">&quot;Example &#39;list&#39; of arguments&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">list</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">list</span> = <span class="ruby-identifier">list</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">specify_encoding_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Keyword completion.  We are specifying a specific set of arguments (CODES</span>
      <span class="ruby-comment"># and CODE_ALIASES - notice the latter is a Hash), and the user may provide</span>
      <span class="ruby-comment"># the shortest unambiguous text.</span>
      <span class="ruby-identifier">code_list</span> = (<span class="ruby-constant">CODE_ALIASES</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">+</span> <span class="ruby-constant">CODES</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;, &#39;</span>)
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--code CODE&quot;</span>, <span class="ruby-constant">CODES</span>, <span class="ruby-constant">CODE_ALIASES</span>, <span class="ruby-string">&quot;Select encoding&quot;</span>,
                <span class="ruby-node">&quot;(#{code_list})&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">encoding</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">encoding</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">optional_option_argument_with_keyword_completion_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Optional &#39;--type&#39; option argument with keyword completion.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--type [TYPE]&quot;</span>, [<span class="ruby-value">:text</span>, <span class="ruby-value">:binary</span>, <span class="ruby-value">:auto</span>],
                <span class="ruby-string">&quot;Select transfer type (text, binary, auto)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">transfer_type</span> = <span class="ruby-identifier">t</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">boolean_verbose_option</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-comment"># Boolean switch.</span>
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-v&quot;</span>, <span class="ruby-string">&quot;--[no-]verbose&quot;</span>, <span class="ruby-string">&quot;Run verbosely&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">verbose</span> = <span class="ruby-identifier">v</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment">#</span>
  <span class="ruby-comment"># Return a structure describing the options.</span>
  <span class="ruby-comment">#</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse</span>(<span class="ruby-identifier">args</span>)
    <span class="ruby-comment"># The options specified on the command line will be collected in</span>
    <span class="ruby-comment"># *options*.</span>

    <span class="ruby-ivar">@options</span> = <span class="ruby-constant">ScriptOptions</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-ivar">@args</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">parser</span><span class="ruby-operator">|</span>
      <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">define_options</span>(<span class="ruby-identifier">parser</span>)
      <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@options</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">attr_reader</span> <span class="ruby-value">:parser</span>, <span class="ruby-value">:options</span>
<span class="ruby-keyword">end</span>  <span class="ruby-comment"># class OptparseExample</span>

<span class="ruby-identifier">example</span> = <span class="ruby-constant">OptparseExample</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">options</span> = <span class="ruby-identifier">example</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-constant">ARGV</span>)
<span class="ruby-identifier">pp</span> <span class="ruby-identifier">options</span> <span class="ruby-comment"># example.options</span>
<span class="ruby-identifier">pp</span> <span class="ruby-constant">ARGV</span>
</pre>

<h3 id="class-OptionParser-label-Shell+Completion">Shell <a href="OptionParser/Completion.html"><code>Completion</code></a><span><a href="#class-OptionParser-label-Shell+Completion">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>For modern shells (e.g. bash, zsh, etc.), you can use shell completion for command line options.</p>

<h3 id="class-OptionParser-label-Further+documentation">Further documentation<span><a href="#class-OptionParser-label-Further+documentation">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The above examples, along with the accompanying <a href="optparse/tutorial_rdoc.html">Tutorial</a>, should be enough to learn how to use this class. If you have any questions, file a ticket at <a href="http://bugs.ruby-lang.org">bugs.ruby-lang.org</a>.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="DecimalInteger">DecimalInteger
          <dd><p>Decimal integer format, to be converted to Integer.</p>
          <dt id="DecimalNumeric">DecimalNumeric
          <dd><p>Decimal integer/float number format, to be converted to Integer for integer format, Float for float format.</p>
          <dt id="OctalInteger">OctalInteger
          <dd><p>Ruby/C like octal/hexadecimal/binary integer format, to be converted to Integer.</p>
          <dt id="Version">Version
          <dd>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-banner" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">banner</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p>Heading banner preceding summary.</p>
              </div>
            </div>
          <div id="attribute-i-default_argv" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">default_argv</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Strings to be parsed in default.</p>
              </div>
            </div>
          <div id="attribute-i-program_name" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">program_name</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p>Program name to be emitted in error message and default banner, defaults to $0.</p>
              </div>
            </div>
          <div id="attribute-i-raise_unknown" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">raise_unknown</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Whether to raise at unknown option.</p>
              </div>
            </div>
          <div id="attribute-i-release" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">release</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p>Release code</p>
              </div>
            </div>
          <div id="attribute-i-require_exact" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">require_exact</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Whether to require that options match exactly (disallows providing abbreviated long option as short option).</p>
              </div>
            </div>
          <div id="attribute-i-set_banner" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">set_banner</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p>Heading banner preceding summary.</p>
              </div>
            </div>
          <div id="attribute-i-set_program_name" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">set_program_name</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p>Program name to be emitted in error message and default banner, defaults to $0.</p>
              </div>
            </div>
          <div id="attribute-i-set_summary_indent" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">set_summary_indent</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Indentation for summary. Must be String (or have + String method).</p>
              </div>
            </div>
          <div id="attribute-i-set_summary_width" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">set_summary_width</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Width for option list portion of summary. Must be Numeric.</p>
              </div>
            </div>
          <div id="attribute-i-summary_indent" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">summary_indent</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Indentation for summary. Must be String (or have + String method).</p>
              </div>
            </div>
          <div id="attribute-i-summary_width" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">summary_width</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Width for option list portion of summary. Must be Numeric.</p>
              </div>
            </div>
          <div id="attribute-i-version" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">version</span><span
                class="attribute-access-type">[W]</span>
            </div>

            <div class="method-description">
              <p><a href="OptionParser.html#Version"><code>Version</code></a></p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-accept" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">accept</span><span
                                class="method-args">(*args, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>See <a href="OptionParser.html#method-i-accept"><code>accept</code></a>.</p>

                              <div class="method-source-code" id="accept-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1190</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">accept</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-identifier">top</span>.<span class="ruby-identifier">accept</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-each_const" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_const</span><span
                                class="method-args">(path, base = ::Object)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="each_const-source">
            <pre><span class="ruby-comment"># File optparse/version.rb, line 50</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_const</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">base</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Object</span>)
  <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/::|\//</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">base</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span>, <span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>, <span class="ruby-identifier">path</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Module</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">klass</span>
    <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp">/#{name}/i</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-identifier">c</span>) <span class="ruby-keyword">or</span> <span class="ruby-keyword">next</span>
      <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">c</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-getopts" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">getopts</span><span
                                class="method-args">(*args, symbolize_names: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>See <a href="OptionParser.html#method-i-getopts"><code>getopts</code></a>.</p>

                              <div class="method-source-code" id="getopts-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1822</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">getopts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">new</span>.<span class="ruby-identifier">getopts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-identifier">symbolize_names</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-inc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inc</span><span
                                class="method-args">(arg, default = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an incremented value of <code>default</code> according to <code>arg</code>.</p>

                              <div class="method-source-code" id="inc-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1124</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">inc</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-identifier">default</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">arg</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Integer</span>
    <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">nonzero?</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">default</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(banner = nil, width = 32, indent = &#39; &#39; * 4) { |self| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initializes the instance and yields itself if called with a block.</p>
<dl class="rdoc-list note-list"><dt><code>banner</code>
<dd>
<p>Banner message.</p>
</dd><dt><code>width</code>
<dd>
<p>Summary width.</p>
</dd><dt><code>indent</code>
<dd>
<p>Summary indent.</p>
</dd></dl>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1143</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">banner</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">width</span> = <span class="ruby-value">32</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">*</span> <span class="ruby-value">4</span>)
  <span class="ruby-ivar">@stack</span> = [<span class="ruby-constant">DefaultList</span>, <span class="ruby-constant">List</span>.<span class="ruby-identifier">new</span>, <span class="ruby-constant">List</span>.<span class="ruby-identifier">new</span>]
  <span class="ruby-ivar">@program_name</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@banner</span> = <span class="ruby-identifier">banner</span>
  <span class="ruby-ivar">@summary_width</span> = <span class="ruby-identifier">width</span>
  <span class="ruby-ivar">@summary_indent</span> = <span class="ruby-identifier">indent</span>
  <span class="ruby-ivar">@default_argv</span> = <span class="ruby-constant">ARGV</span>
  <span class="ruby-ivar">@require_exact</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@raise_unknown</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">add_officious</span>
  <span class="ruby-keyword">yield</span> <span class="ruby-keyword">self</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-reject" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">reject</span><span
                                class="method-args">(*args, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>See <a href="OptionParser.html#method-i-reject"><code>reject</code></a>.</p>

                              <div class="method-source-code" id="reject-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1203</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">reject</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-identifier">top</span>.<span class="ruby-identifier">reject</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-search_const" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">search_const</span><span
                                class="method-args">(klass, name) { |klass, cname, const| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="search_const-source">
            <pre><span class="ruby-comment"># File optparse/version.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">search_const</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">klasses</span> = [<span class="ruby-identifier">klass</span>]
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">klasses</span>.<span class="ruby-identifier">shift</span>
    <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cname</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-identifier">cname</span>) <span class="ruby-keyword">or</span> <span class="ruby-keyword">next</span>
      <span class="ruby-identifier">const</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">cname</span>)
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">cname</span>, <span class="ruby-identifier">const</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">cname</span>
      <span class="ruby-identifier">klasses</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">const</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Module</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">const</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">const</span> <span class="ruby-operator">!=</span> <span class="ruby-operator">::</span><span class="ruby-constant">Object</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-show_version" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">show_version</span><span
                                class="method-args">(*pkgs)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="show_version-source">
            <pre><span class="ruby-comment"># File optparse/version.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">show_version</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">pkgs</span>)
  <span class="ruby-identifier">progname</span> = <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">options</span>.<span class="ruby-identifier">program_name</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">show</span> = <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span>, <span class="ruby-identifier">cname</span>, <span class="ruby-identifier">version</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">str</span> = <span class="ruby-node">&quot;#{progname}&quot;</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">klass</span> <span class="ruby-operator">==</span> <span class="ruby-operator">::</span><span class="ruby-constant">Object</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">cname</span> <span class="ruby-operator">==</span> <span class="ruby-value">:VERSION</span>
      <span class="ruby-identifier">version</span> = <span class="ruby-identifier">version</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;.&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">version</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;: #{klass}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">klass</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Object</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; version #{version}&quot;</span>
    <span class="ruby-keyword">end</span>
    [<span class="ruby-value">:Release</span>, <span class="ruby-value">:RELEASE</span>].<span class="ruby-identifier">find</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rel</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-identifier">rel</span>)
        <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; (#{klass.const_get(rel)})&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">str</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">pkgs</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">pkgs</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&quot;all&quot;</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">search_const</span>(<span class="ruby-operator">::</span><span class="ruby-constant">Object</span>, <span class="ruby-regexp">/\AV(?:ERSION|ersion)\z/</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span>, <span class="ruby-identifier">cname</span>, <span class="ruby-identifier">version</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">cname</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?e</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:Version</span>)
        <span class="ruby-identifier">show</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-identifier">cname</span>.<span class="ruby-identifier">intern</span>, <span class="ruby-identifier">version</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">pkgs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pkg</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">pkg</span> = <span class="ruby-identifier">pkg</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/::|\//</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-operator">::</span><span class="ruby-constant">Object</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">c</span>)}
        <span class="ruby-identifier">v</span> = <span class="ruby-keyword">case</span>
            <span class="ruby-keyword">when</span> <span class="ruby-identifier">pkg</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:Version</span>)
              <span class="ruby-identifier">pkg</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">n</span> = <span class="ruby-value">:Version</span>)
            <span class="ruby-keyword">when</span> <span class="ruby-identifier">pkg</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:VERSION</span>)
              <span class="ruby-identifier">pkg</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">n</span> = <span class="ruby-value">:VERSION</span>)
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">n</span> = <span class="ruby-keyword">nil</span>
              <span class="ruby-string">&quot;unknown&quot;</span>
            <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">show</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">pkg</span>, <span class="ruby-identifier">n</span>, <span class="ruby-identifier">v</span>)
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">NameError</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-terminate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">terminate</span><span
                                class="method-args">(arg = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="terminate-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1170</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">terminate</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">throw</span> <span class="ruby-value">:terminate</span>, <span class="ruby-identifier">arg</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-top" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">top</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="top-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1175</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">top</span>() <span class="ruby-constant">DefaultList</span> <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-with" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">with</span><span
                                class="method-args">(*args, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initializes a new instance and evaluates the optional block in context of the instance. Arguments <code>args</code> are passed to <a href="OptionParser.html#method-i-new"><code>new</code></a>, see there for description of parameters.</p>

<p>This method is <strong>deprecated</strong>, its behavior corresponds to the older <a href="OptionParser.html#method-i-new"><code>new</code></a> method.</p>

                              <div class="method-source-code" id="with-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1115</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">with</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">opts</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-abort" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">abort</span><span
                                class="method-args">(mesg = $!)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="abort-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1291</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">abort</span>(<span class="ruby-identifier">mesg</span> = <span class="ruby-identifier">$!</span>)
  <span class="ruby-keyword">super</span>(<span class="ruby-node">&quot;#{program_name}: #{mesg}&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-accept" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">accept</span><span
                                class="method-args">(*args, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Directs to accept specified class <code>t</code>. The argument string is passed to the block in which it should be converted to the desired class.</p>
<dl class="rdoc-list note-list"><dt><code>t</code>
<dd>
<p>Argument class specifier, any object including Class.</p>
</dd><dt><code>pat</code>
<dd>
<p>Pattern for argument, defaults to <code>t</code> if it responds to match.</p>
</dd></dl>

<pre class="ruby"><span class="ruby-identifier">accept</span>(<span class="ruby-identifier">t</span>, <span class="ruby-identifier">pat</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
</pre>

                              <div class="method-source-code" id="accept-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1186</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">accept</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-identifier">top</span>.<span class="ruby-identifier">accept</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-additional_message" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">additional_message</span><span
                                class="method-args">(typ, opt)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns additional info.</p>

                              <div class="method-source-code" id="additional_message-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1873</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">additional_message</span>(<span class="ruby-identifier">typ</span>, <span class="ruby-identifier">opt</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">typ</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">opt</span> <span class="ruby-keyword">and</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">DidYouMean</span><span class="ruby-operator">::</span><span class="ruby-constant">SpellChecker</span>)
  <span class="ruby-identifier">all_candidates</span> = []
  <span class="ruby-identifier">visit</span>(<span class="ruby-value">:get_candidates</span>, <span class="ruby-identifier">typ</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">candidates</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">all_candidates</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">candidates</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">all_candidates</span>.<span class="ruby-identifier">select!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">cand</span><span class="ruby-operator">|</span> <span class="ruby-identifier">cand</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) }
  <span class="ruby-identifier">checker</span> = <span class="ruby-constant">DidYouMean</span><span class="ruby-operator">::</span><span class="ruby-constant">SpellChecker</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">dictionary:</span> <span class="ruby-identifier">all_candidates</span>)
  <span class="ruby-constant">DidYouMean</span>.<span class="ruby-identifier">formatter</span>.<span class="ruby-identifier">message_for</span>(<span class="ruby-identifier">all_candidates</span> <span class="ruby-operator">&amp;</span> <span class="ruby-identifier">checker</span>.<span class="ruby-identifier">correct</span>(<span class="ruby-identifier">opt</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-banner" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">banner</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Heading banner preceding summary.</p>

                              <div class="method-source-code" id="banner-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1235</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">banner</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@banner</span>
    <span class="ruby-ivar">@banner</span> = <span class="ruby-node">+&quot;Usage: #{program_name} [options]&quot;</span>
    <span class="ruby-identifier">visit</span>(<span class="ruby-value">:add_banner</span>, <span class="ruby-ivar">@banner</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@banner</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-base" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">base</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Subject of <a href="OptionParser.html#method-i-on_tail"><code>on_tail</code></a>.</p>

                              <div class="method-source-code" id="base-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1305</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">base</span>
  <span class="ruby-ivar">@stack</span>[<span class="ruby-value">1</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-candidate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">candidate</span><span
                                class="method-args">(word)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="candidate-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1884</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">candidate</span>(<span class="ruby-identifier">word</span>)
  <span class="ruby-identifier">list</span> = []
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">word</span>
  <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;-&#39;</span>
    <span class="ruby-identifier">long</span> = <span class="ruby-identifier">short</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A--/</span>
    <span class="ruby-identifier">word</span>, <span class="ruby-identifier">arg</span> = <span class="ruby-identifier">word</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/=/</span>, <span class="ruby-value">2</span>)
    <span class="ruby-identifier">argpat</span> = <span class="ruby-constant">Completion</span>.<span class="ruby-identifier">regexp</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-keyword">false</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">arg</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">long</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\A-/</span>
    <span class="ruby-identifier">short</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">pat</span> = <span class="ruby-constant">Completion</span>.<span class="ruby-identifier">regexp</span>(<span class="ruby-identifier">word</span>, <span class="ruby-identifier">long</span>)
  <span class="ruby-identifier">visit</span>(<span class="ruby-value">:each_option</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opt</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Switch</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opt</span>
    <span class="ruby-identifier">opts</span> = (<span class="ruby-identifier">long</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">long</span> <span class="ruby-operator">:</span> []) <span class="ruby-operator">+</span> (<span class="ruby-identifier">short</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">short</span> <span class="ruby-operator">:</span> [])
    <span class="ruby-identifier">opts</span> = <span class="ruby-constant">Completion</span>.<span class="ruby-identifier">candidate</span>(<span class="ruby-identifier">word</span>, <span class="ruby-keyword">true</span>, <span class="ruby-identifier">pat</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">opts</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:each</span>)).<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:first</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">pat</span>
    <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\A=/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">arg</span>
      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">map!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">sw</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sw</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;=&quot;</span>}
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg</span> <span class="ruby-keyword">and</span> <span class="ruby-constant">CompletingHash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">pattern</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">candidate</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-keyword">false</span>, <span class="ruby-identifier">argpat</span>)
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">map!</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:last</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">list</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">opts</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">list</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-def_head_option" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">def_head_option</span><span
                                class="method-args">(*opts, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="OptionParser.html#method-i-define_head">define_head</a>
                            </div>
                          </div>

                  <div id="method-i-def_option" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">def_option</span><span
                                class="method-args">(*opts, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="OptionParser.html#method-i-define">define</a>
                            </div>
                          </div>

                  <div id="method-i-def_tail_option" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">def_tail_option</span><span
                                class="method-args">(*opts, &amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="OptionParser.html#method-i-define_tail">define_tail</a>
                            </div>
                          </div>

                  <div id="method-i-define" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          define(*params, &amp;block)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

                              <div class="method-source-code" id="define-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1540</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">top</span>.<span class="ruby-identifier">append</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">sw</span> = <span class="ruby-identifier">make_switch</span>(<span class="ruby-identifier">opts</span>, <span class="ruby-identifier">block</span>)))
  <span class="ruby-identifier">sw</span>[<span class="ruby-value">0</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="OptionParser.html#method-i-def_option">def_option</a>
                            </div>

                          </div>

                  <div id="method-i-define_by_keywords" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          define_by_keywords(options, method, **params)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

                              <div class="method-source-code" id="define_by_keywords-source">
            <pre><span class="ruby-comment"># File optparse/kwargs.rb, line 10</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_by_keywords</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">meth</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">opts</span>)
  <span class="ruby-identifier">meth</span>.<span class="ruby-identifier">parameters</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span>, <span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:key</span>, <span class="ruby-value">:keyreq</span>
      <span class="ruby-identifier">op</span>, <span class="ruby-identifier">cl</span> = <span class="ruby-operator">*</span>(<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:key</span> <span class="ruby-operator">?</span> <span class="ruby-node">%w&quot;[ ]&quot;</span> <span class="ruby-operator">:</span> [<span class="ruby-string">&quot;&quot;</span>, <span class="ruby-string">&quot;&quot;</span>])
      <span class="ruby-identifier">define</span>(<span class="ruby-node">&quot;--#{name}=#{op}#{name.upcase}#{cl}&quot;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>[<span class="ruby-identifier">name</span>]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">options</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">o</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">options</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-define_head" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          define_head(*params, &amp;block)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

                              <div class="method-source-code" id="define_head-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1561</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_head</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">top</span>.<span class="ruby-identifier">prepend</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">sw</span> = <span class="ruby-identifier">make_switch</span>(<span class="ruby-identifier">opts</span>, <span class="ruby-identifier">block</span>)))
  <span class="ruby-identifier">sw</span>[<span class="ruby-value">0</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="OptionParser.html#method-i-def_head_option">def_head_option</a>
                            </div>

                          </div>

                  <div id="method-i-define_tail" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          define_tail(*params, &amp;block)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

                              <div class="method-source-code" id="define_tail-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1584</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_tail</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">append</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">sw</span> = <span class="ruby-identifier">make_switch</span>(<span class="ruby-identifier">opts</span>, <span class="ruby-identifier">block</span>)))
  <span class="ruby-identifier">sw</span>[<span class="ruby-value">0</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="OptionParser.html#method-i-def_tail_option">def_tail_option</a>
                            </div>

                          </div>

                  <div id="method-i-environment" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">environment</span><span
                                class="method-args">(env = File.basename($0, &#39;.*&#39;))</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses environment variable <code>env</code> or its uppercase with splitting like a shell.</p>

<p><code>env</code> defaults to the basename of the program.</p>

                              <div class="method-source-code" id="environment-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1957</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">environment</span>(<span class="ruby-identifier">env</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">$0</span>, <span class="ruby-string">&#39;.*&#39;</span>))
  <span class="ruby-identifier">env</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-identifier">env</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">ENV</span>[<span class="ruby-identifier">env</span>.<span class="ruby-identifier">upcase</span>] <span class="ruby-keyword">or</span> <span class="ruby-keyword">return</span>
  <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;shellwords&#39;</span>
  <span class="ruby-identifier">parse</span>(<span class="ruby-operator">*</span><span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">env</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getopts" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">getopts</span><span
                                class="method-args">(*args, symbolize_names: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Wrapper method for getopts.rb.</p>

<pre class="ruby"><span class="ruby-identifier">params</span> = <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">getopts</span>(<span class="ruby-string">&quot;ab:&quot;</span>, <span class="ruby-string">&quot;foo&quot;</span>, <span class="ruby-string">&quot;bar:&quot;</span>, <span class="ruby-string">&quot;zot:Z;zot option&quot;</span>)
<span class="ruby-comment"># params[&quot;a&quot;] = true   # -a</span>
<span class="ruby-comment"># params[&quot;b&quot;] = &quot;1&quot;    # -b1</span>
<span class="ruby-comment"># params[&quot;foo&quot;] = &quot;1&quot;  # --foo</span>
<span class="ruby-comment"># params[&quot;bar&quot;] = &quot;x&quot;  # --bar x</span>
<span class="ruby-comment"># params[&quot;zot&quot;] = &quot;z&quot;  # --zot Z</span>
</pre>

<p>Option <code>symbolize_names</code> (boolean) specifies whether returned Hash keys should be Symbols; defaults to <code>false</code> (use Strings).</p>

<pre class="ruby"><span class="ruby-identifier">params</span> = <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">getopts</span>(<span class="ruby-string">&quot;ab:&quot;</span>, <span class="ruby-string">&quot;foo&quot;</span>, <span class="ruby-string">&quot;bar:&quot;</span>, <span class="ruby-string">&quot;zot:Z;zot option&quot;</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-comment"># params[:a] = true   # -a</span>
<span class="ruby-comment"># params[:b] = &quot;1&quot;    # -b1</span>
<span class="ruby-comment"># params[:foo] = &quot;1&quot;  # --foo</span>
<span class="ruby-comment"># params[:bar] = &quot;x&quot;  # --bar x</span>
<span class="ruby-comment"># params[:zot] = &quot;z&quot;  # --zot Z</span>
</pre>

                              <div class="method-source-code" id="getopts-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1787</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">getopts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-value">symbolize_names:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">argv</span> = <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">default_argv</span>
  <span class="ruby-identifier">single_options</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">long_options</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>

  <span class="ruby-identifier">result</span> = {}

  <span class="ruby-identifier">single_options</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(.)(:)?/</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opt</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">val</span>
      <span class="ruby-identifier">result</span>[<span class="ruby-identifier">opt</span>] = <span class="ruby-keyword">nil</span>
      <span class="ruby-identifier">define</span>(<span class="ruby-node">&quot;-#{opt} VAL&quot;</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">result</span>[<span class="ruby-identifier">opt</span>] = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">define</span>(<span class="ruby-node">&quot;-#{opt}&quot;</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">single_options</span>

  <span class="ruby-identifier">long_options</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">arg</span>, <span class="ruby-identifier">desc</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;;&#39;</span>, <span class="ruby-value">2</span>)
    <span class="ruby-identifier">opt</span>, <span class="ruby-identifier">val</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;:&#39;</span>, <span class="ruby-value">2</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">val</span>
      <span class="ruby-identifier">result</span>[<span class="ruby-identifier">opt</span>] = <span class="ruby-identifier">val</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">val</span>
      <span class="ruby-identifier">define</span>(<span class="ruby-node">&quot;--#{opt}=#{result[opt] || &quot;VAL&quot;}&quot;</span>, <span class="ruby-operator">*</span>[<span class="ruby-identifier">desc</span>].<span class="ruby-identifier">compact</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">result</span>[<span class="ruby-identifier">opt</span>] = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">define</span>(<span class="ruby-node">&quot;--#{opt}&quot;</span>, <span class="ruby-operator">*</span>[<span class="ruby-identifier">desc</span>].<span class="ruby-identifier">compact</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">parse_in_order</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-identifier">result</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:[]=</span>))
  <span class="ruby-identifier">symbolize_names</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">transform_keys</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:to_sym</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-help" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">help</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns option summary string.</p>

                              <div class="method-source-code" id="help-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1347</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">help</span>; <span class="ruby-identifier">summarize</span>(<span class="ruby-node">&quot;#{banner}&quot;</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\n?\z/</span>, <span class="ruby-string">&quot;\n&quot;</span>)) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="OptionParser.html#method-i-to_s">to_s</a>
                            </div>

                          </div>

                  <div id="method-i-inc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inc</span><span
                                class="method-args">(*args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="inc-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1132</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inc</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">inc</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-load" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">load</span><span
                                class="method-args">(filename = nil, into: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Loads options from file names as <code>filename</code>. Does nothing when the file is not present. Returns whether successfully loaded.</p>

<p><code>filename</code> defaults to basename of the program without suffix in a directory ~/.options, then the basename with ‘.options’ suffix under XDG and Haiku standard places.</p>

<p>The optional <code>into</code> keyword argument works exactly like that accepted in method <a href="OptionParser.html#method-i-parse"><code>parse</code></a>.</p>

                              <div class="method-source-code" id="load-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1925</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">load</span>(<span class="ruby-identifier">filename</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">filename</span>
    <span class="ruby-identifier">basename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">$0</span>, <span class="ruby-string">&#39;.*&#39;</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-string">&#39;~/.options&#39;</span>), <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">basename</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;.options&quot;</span>
    <span class="ruby-keyword">return</span> [
      <span class="ruby-comment"># XDG</span>
      <span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;XDG_CONFIG_HOME&#39;</span>],
      <span class="ruby-string">&#39;~/.config&#39;</span>,
      <span class="ruby-operator">*</span><span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;XDG_CONFIG_DIRS&#39;</span>]&amp;.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>),

      <span class="ruby-comment"># Haiku</span>
      <span class="ruby-string">&#39;~/config/settings&#39;</span>,
    ].<span class="ruby-identifier">any?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dir</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">dir</span>), <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
    }
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">parse</span>(<span class="ruby-operator">*</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value">chomp:</span> <span class="ruby-keyword">true</span>), <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>)
    <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOTDIR</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-make_switch" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          make_switch(params, block = nil)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

                              <div class="method-source-code" id="make_switch-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1402</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">make_switch</span>(<span class="ruby-identifier">opts</span>, <span class="ruby-identifier">block</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">short</span>, <span class="ruby-identifier">long</span>, <span class="ruby-identifier">nolong</span>, <span class="ruby-identifier">style</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">conv</span>, <span class="ruby-identifier">not_pattern</span>, <span class="ruby-identifier">not_conv</span>, <span class="ruby-identifier">not_style</span> = [], [], []
  <span class="ruby-identifier">ldesc</span>, <span class="ruby-identifier">sdesc</span>, <span class="ruby-identifier">desc</span>, <span class="ruby-identifier">arg</span> = [], [], []
  <span class="ruby-identifier">default_style</span> = <span class="ruby-constant">Switch</span><span class="ruby-operator">::</span><span class="ruby-constant">NoArgument</span>
  <span class="ruby-identifier">default_pattern</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">klass</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">q</span>, <span class="ruby-identifier">a</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">has_arg</span> = <span class="ruby-keyword">false</span>

  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
    <span class="ruby-comment"># argument class</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">o</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pat</span>, <span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-string">&#39;type&#39;</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">not_style</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">not_style</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">Switch</span><span class="ruby-operator">::</span><span class="ruby-constant">NoArgument</span>
        <span class="ruby-identifier">not_pattern</span>, <span class="ruby-identifier">not_conv</span> = <span class="ruby-identifier">pat</span>, <span class="ruby-identifier">c</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">pat</span>, <span class="ruby-identifier">c</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># directly specified pattern(any object possible to match)</span>
    <span class="ruby-keyword">if</span> (<span class="ruby-operator">!</span>(<span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Symbol</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">o</span>)) <span class="ruby-keyword">and</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:match</span>)
      <span class="ruby-identifier">pattern</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-string">&#39;pattern&#39;</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:convert</span>)
        <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:convert</span>).<span class="ruby-identifier">to_proc</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">conv</span> = <span class="ruby-constant">SPLAT_PROC</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># anything others</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">o</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">Proc</span>, <span class="ruby-constant">Method</span>
      <span class="ruby-identifier">block</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">block</span>, <span class="ruby-string">&#39;block&#39;</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>, <span class="ruby-constant">Hash</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">pattern</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">CompletingHash</span>
      <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
        <span class="ruby-identifier">pattern</span> = <span class="ruby-constant">CompletingHash</span>.<span class="ruby-identifier">new</span>
        <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:convert</span>).<span class="ruby-identifier">to_proc</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:convert</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;argument pattern given twice&quot;</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">o</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">pat</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pattern</span>[<span class="ruby-identifier">pat</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">0</span>) {<span class="ruby-identifier">pat</span>}}
    <span class="ruby-keyword">when</span> <span class="ruby-constant">Module</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;unsupported argument type: #{o}&quot;</span>, <span class="ruby-constant">ParseError</span>.<span class="ruby-identifier">filter_backtrace</span>(<span class="ruby-identifier">caller</span>(<span class="ruby-value">4</span>))
    <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">ArgumentStyle</span>.<span class="ruby-identifier">keys</span>
      <span class="ruby-identifier">style</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-constant">ArgumentStyle</span>[<span class="ruby-identifier">o</span>], <span class="ruby-identifier">style</span>, <span class="ruby-string">&#39;style&#39;</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^--no-([^\[\]=\s]*)(.+)?/</span>
      <span class="ruby-identifier">q</span>, <span class="ruby-identifier">a</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
      <span class="ruby-identifier">o</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Object</span> <span class="ruby-operator">:</span> <span class="ruby-constant">TrueClass</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-string">&#39;type&#39;</span>)
      <span class="ruby-identifier">not_pattern</span>, <span class="ruby-identifier">not_conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">o</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">not_style</span>
      <span class="ruby-identifier">not_style</span> = (<span class="ruby-identifier">not_style</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default_style</span>).<span class="ruby-identifier">guess</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">a</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">a</span>
      <span class="ruby-identifier">default_style</span> = <span class="ruby-constant">Switch</span><span class="ruby-operator">::</span><span class="ruby-constant">NoArgument</span>
      <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-constant">FalseClass</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
      <span class="ruby-identifier">ldesc</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--no-#{q}&quot;</span>
      (<span class="ruby-identifier">q</span> = <span class="ruby-identifier">q</span>.<span class="ruby-identifier">downcase</span>).<span class="ruby-identifier">tr!</span>(<span class="ruby-string">&#39;_&#39;</span>, <span class="ruby-string">&#39;-&#39;</span>)
      <span class="ruby-identifier">long</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;no-#{q}&quot;</span>
      <span class="ruby-identifier">nolong</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">q</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^--\[no-\]([^\[\]=\s]*)(.+)?/</span>
      <span class="ruby-identifier">q</span>, <span class="ruby-identifier">a</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
      <span class="ruby-identifier">o</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Object</span> <span class="ruby-operator">:</span> <span class="ruby-constant">TrueClass</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-string">&#39;type&#39;</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">a</span>
        <span class="ruby-identifier">default_style</span> = <span class="ruby-identifier">default_style</span>.<span class="ruby-identifier">guess</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">a</span>)
        <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">o</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">ldesc</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--[no-]#{q}&quot;</span>
      (<span class="ruby-identifier">o</span> = <span class="ruby-identifier">q</span>.<span class="ruby-identifier">downcase</span>).<span class="ruby-identifier">tr!</span>(<span class="ruby-string">&#39;_&#39;</span>, <span class="ruby-string">&#39;-&#39;</span>)
      <span class="ruby-identifier">long</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">o</span>
      <span class="ruby-identifier">not_pattern</span>, <span class="ruby-identifier">not_conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-constant">FalseClass</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">not_style</span>
      <span class="ruby-identifier">not_style</span> = <span class="ruby-constant">Switch</span><span class="ruby-operator">::</span><span class="ruby-constant">NoArgument</span>
      <span class="ruby-identifier">nolong</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;no-#{o}&quot;</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^--([^\[\]=\s]*)(.+)?/</span>
      <span class="ruby-identifier">q</span>, <span class="ruby-identifier">a</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">a</span>
        <span class="ruby-identifier">o</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-constant">NilClass</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-string">&#39;type&#39;</span>)
        <span class="ruby-identifier">default_style</span> = <span class="ruby-identifier">default_style</span>.<span class="ruby-identifier">guess</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">a</span>)
        <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">o</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">ldesc</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--#{q}&quot;</span>
      (<span class="ruby-identifier">o</span> = <span class="ruby-identifier">q</span>.<span class="ruby-identifier">downcase</span>).<span class="ruby-identifier">tr!</span>(<span class="ruby-string">&#39;_&#39;</span>, <span class="ruby-string">&#39;-&#39;</span>)
      <span class="ruby-identifier">long</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">o</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/</span>
      <span class="ruby-identifier">q</span>, <span class="ruby-identifier">a</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
      <span class="ruby-identifier">o</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-constant">Object</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-string">&#39;type&#39;</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">a</span>
        <span class="ruby-identifier">default_style</span> = <span class="ruby-identifier">default_style</span>.<span class="ruby-identifier">guess</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">a</span>)
        <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">o</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">has_arg</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">sdesc</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;-#{q}&quot;</span>
      <span class="ruby-identifier">short</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">q</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^-(.)(.+)?/</span>
      <span class="ruby-identifier">q</span>, <span class="ruby-identifier">a</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">a</span>
        <span class="ruby-identifier">o</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-constant">NilClass</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-string">&#39;type&#39;</span>)
        <span class="ruby-identifier">default_style</span> = <span class="ruby-identifier">default_style</span>.<span class="ruby-identifier">guess</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">a</span>)
        <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">o</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">sdesc</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;-#{q}&quot;</span>
      <span class="ruby-identifier">short</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">q</span>
    <span class="ruby-keyword">when</span> <span class="ruby-regexp">/^=/</span>
      <span class="ruby-identifier">style</span> = <span class="ruby-identifier">notwice</span>(<span class="ruby-identifier">default_style</span>.<span class="ruby-identifier">guess</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">o</span>), <span class="ruby-identifier">style</span>, <span class="ruby-string">&#39;style&#39;</span>)
      <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-constant">Object</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">desc</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">o</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">o</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">default_pattern</span>, <span class="ruby-identifier">conv</span> = <span class="ruby-identifier">search</span>(<span class="ruby-value">:atype</span>, <span class="ruby-identifier">default_style</span>.<span class="ruby-identifier">pattern</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">default_pattern</span>
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">short</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">long</span>.<span class="ruby-identifier">empty?</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_arg</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">default_style</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Switch</span><span class="ruby-operator">::</span><span class="ruby-constant">NoArgument</span>
      <span class="ruby-identifier">default_style</span> = <span class="ruby-constant">Switch</span><span class="ruby-operator">::</span><span class="ruby-constant">RequiredArgument</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">s</span> = (<span class="ruby-identifier">style</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default_style</span>).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pattern</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default_pattern</span>,
                                     <span class="ruby-identifier">conv</span>, <span class="ruby-identifier">sdesc</span>, <span class="ruby-identifier">ldesc</span>, <span class="ruby-identifier">arg</span>, <span class="ruby-identifier">desc</span>, <span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">block</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">style</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">pattern</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;no switch given&quot;</span>, <span class="ruby-constant">ParseError</span>.<span class="ruby-identifier">filter_backtrace</span>(<span class="ruby-identifier">caller</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">s</span> = <span class="ruby-identifier">desc</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">short</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">pattern</span>
    <span class="ruby-identifier">s</span> = (<span class="ruby-identifier">style</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default_style</span>).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pattern</span>,
                                     <span class="ruby-identifier">conv</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">arg</span>, <span class="ruby-identifier">desc</span>, <span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">short</span>, <span class="ruby-identifier">long</span>,
    (<span class="ruby-identifier">not_style</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">not_pattern</span>, <span class="ruby-identifier">not_conv</span>, <span class="ruby-identifier">sdesc</span>, <span class="ruby-identifier">ldesc</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">desc</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">not_style</span>),
    <span class="ruby-identifier">nolong</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">() { |self| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Pushes a new <a href="OptionParser/List.html"><code>List</code></a>.</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">new</span>
  <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">List</span>.<span class="ruby-identifier">new</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-on" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          on(*params, &amp;block)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

                              <div class="method-source-code" id="on-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1550</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">on</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">define</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-on_head" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          on_head(*params, &amp;block)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

<p>The new option is added at the head of the summary.</p>

                              <div class="method-source-code" id="on_head-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1573</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">on_head</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">define_head</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-on_tail" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          on_tail(*params, &amp;block)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option from the given parameters <code>params</code>. See <a href="optparse/option_params_rdoc.html">Parameters for New Options</a>.</p>

<p>The block, if given, is the handler for the created option. When the option is encountered during command-line parsing, the block is called with the argument given for the option, if any. See <a href="optparse/option_params_rdoc.html#label-Option+Handlers">Option Handlers</a>.</p>

<p>The new option is added at the tail of the summary.</p>

                              <div class="method-source-code" id="on_tail-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1597</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">on_tail</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">define_tail</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-order" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">order</span><span
                                class="method-args">(*argv, into: nil, &amp;nonopt)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses command line arguments <code>argv</code> in order. When a block is given, each non-option argument is yielded. When optional <code>into</code> keyword argument is provided, the parsed option values are stored there via <code>[]=</code> method (so it can be Hash, or OpenStruct, or other similar object).</p>

<p>Returns the rest of <code>argv</code> left unparsed.</p>

                              <div class="method-source-code" id="order-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1619</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">order</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">nonopt</span>)
  <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">dup</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword">and</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>]
  <span class="ruby-identifier">order!</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">nonopt</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-order-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">order!</span><span
                                class="method-args">(argv = default_argv, into: nil, &amp;nonopt)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Same as <a href="OptionParser.html#method-i-order"><code>order</code></a>, but removes switches destructively. Non-option arguments remain in <code>argv</code>.</p>

                              <div class="method-source-code" id="order-21-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1628</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">order!</span>(<span class="ruby-identifier">argv</span> = <span class="ruby-identifier">default_argv</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">nonopt</span>)
  <span class="ruby-identifier">setter</span> = <span class="ruby-operator">-&gt;</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">val</span>) {<span class="ruby-identifier">into</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">val</span>} <span class="ruby-keyword">if</span> <span class="ruby-identifier">into</span>
  <span class="ruby-identifier">parse_in_order</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-identifier">setter</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">nonopt</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parse" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse</span><span
                                class="method-args">(*argv, into: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses command line arguments <code>argv</code> in order when environment variable POSIXLY_CORRECT is set, and in permutation mode otherwise. When optional <code>into</code> keyword argument is provided, the parsed option values are stored there via <code>[]=</code> method (so it can be Hash, or OpenStruct, or other similar object).</p>

                              <div class="method-source-code" id="parse-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1751</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">dup</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword">and</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>]
  <span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parse-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse!</span><span
                                class="method-args">(argv = default_argv, into: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Same as <a href="OptionParser.html#method-i-parse"><code>parse</code></a>, but removes switches destructively. Non-option arguments remain in <code>argv</code>.</p>

                              <div class="method-source-code" id="parse-21-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1760</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse!</span>(<span class="ruby-identifier">argv</span> = <span class="ruby-identifier">default_argv</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;POSIXLY_CORRECT&#39;</span>)
    <span class="ruby-identifier">order!</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">permute!</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-permute" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">permute</span><span
                                class="method-args">(*argv, into: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses command line arguments <code>argv</code> in permutation mode and returns list of non-option arguments. When optional <code>into</code> keyword argument is provided, the parsed option values are stored there via <code>[]=</code> method (so it can be Hash, or OpenStruct, or other similar object).</p>

                              <div class="method-source-code" id="permute-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1728</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">permute</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">dup</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-keyword">and</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>]
  <span class="ruby-identifier">permute!</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-permute-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">permute!</span><span
                                class="method-args">(argv = default_argv, into: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Same as <a href="OptionParser.html#method-i-permute"><code>permute</code></a>, but removes switches destructively. Non-option arguments remain in <code>argv</code>.</p>

                              <div class="method-source-code" id="permute-21-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1737</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">permute!</span>(<span class="ruby-identifier">argv</span> = <span class="ruby-identifier">default_argv</span>, <span class="ruby-value">into:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">nonopts</span> = []
  <span class="ruby-identifier">order!</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-value">into:</span> <span class="ruby-identifier">into</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">nonopts</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:&lt;&lt;</span>))
  <span class="ruby-identifier">argv</span>[<span class="ruby-value">0</span>, <span class="ruby-value">0</span>] = <span class="ruby-identifier">nonopts</span>
  <span class="ruby-identifier">argv</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-program_name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">program_name</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Program name to be emitted in error message and default banner, defaults to $0.</p>

                              <div class="method-source-code" id="program_name-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1247</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">program_name</span>
  <span class="ruby-ivar">@program_name</span> <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">$0</span>, <span class="ruby-string">&#39;.*&#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-reject" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">reject</span><span
                                class="method-args">(*args, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Directs to reject specified class argument.</p>
<dl class="rdoc-list note-list"><dt><code>t</code>
<dd>
<p>Argument class specifier, any object including Class.</p>
</dd></dl>

<pre class="ruby"><span class="ruby-identifier">reject</span>(<span class="ruby-identifier">t</span>)
</pre>

                              <div class="method-source-code" id="reject-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1199</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">reject</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-identifier">top</span>.<span class="ruby-identifier">reject</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-release" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">release</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Release code</p>

                              <div class="method-source-code" id="release-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1272</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">release</span>
  (<span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@release</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@release</span>) <span class="ruby-operator">||</span> (<span class="ruby-keyword">defined?</span>(<span class="ruby-operator">::</span><span class="ruby-constant">Release</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">::</span><span class="ruby-constant">Release</span>) <span class="ruby-operator">||</span> (<span class="ruby-keyword">defined?</span>(<span class="ruby-operator">::</span><span class="ruby-constant">RELEASE</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">::</span><span class="ruby-constant">RELEASE</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the last <a href="OptionParser/List.html"><code>List</code></a>.</p>

                              <div class="method-source-code" id="remove-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1324</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove</span>
  <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">pop</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-separator" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">separator</span><span
                                class="method-args">(string)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Add separator in summary.</p>

                              <div class="method-source-code" id="separator-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1606</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">separator</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">top</span>.<span class="ruby-identifier">append</span>(<span class="ruby-identifier">string</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-summarize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">summarize</span><span
                                class="method-args">(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Puts option summary into <code>to</code> and returns <code>to</code>. Yields each line if a block is given.</p>
<dl class="rdoc-list note-list"><dt><code>to</code>
<dd>
<p>Output destination, which must have method &lt;&lt;. Defaults to [].</p>
</dd><dt><code>width</code>
<dd>
<p>Width of left side, defaults to @summary_width.</p>
</dd><dt><code>max</code>
<dd>
<p>Maximum length allowed for left side, defaults to <code>width</code> - 1.</p>
</dd><dt><code>indent</code>
<dd>
<p>Indentation, defaults to @summary_indent.</p>
</dd></dl>

                              <div class="method-source-code" id="summarize-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1337</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">summarize</span>(<span class="ruby-identifier">to</span> = [], <span class="ruby-identifier">width</span> = <span class="ruby-ivar">@summary_width</span>, <span class="ruby-identifier">max</span> = <span class="ruby-identifier">width</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-ivar">@summary_indent</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-identifier">nl</span> = <span class="ruby-string">&quot;\n&quot;</span>
  <span class="ruby-identifier">blk</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">l</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">nl</span>, <span class="ruby-value">-1</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">l</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">l</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">nl</span>)}
  <span class="ruby-identifier">visit</span>(<span class="ruby-value">:summarize</span>, {}, {}, <span class="ruby-identifier">width</span>, <span class="ruby-identifier">max</span>, <span class="ruby-identifier">indent</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-identifier">to</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-terminate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">terminate</span><span
                                class="method-args">(arg = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Terminates option parsing. Optional parameter <code>arg</code> is a string pushed back to be the first non-option argument.</p>

                              <div class="method-source-code" id="terminate-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1167</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">terminate</span>(<span class="ruby-identifier">arg</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">terminate</span>(<span class="ruby-identifier">arg</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_a" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_a</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns option summary list.</p>

                              <div class="method-source-code" id="to_a-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1376</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_a</span>; <span class="ruby-identifier">summarize</span>(<span class="ruby-node">&quot;#{banner}&quot;</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/^/</span>)) <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">to_s</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="OptionParser.html#method-i-help">help</a>
                            </div>
                          </div>

                  <div id="method-i-top" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">top</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Subject of <a href="OptionParser.html#method-i-on"><code>on</code></a> / <a href="OptionParser.html#method-i-on_head"><code>on_head</code></a>, <a href="OptionParser.html#method-i-accept"><code>accept</code></a> / <a href="OptionParser.html#method-i-reject"><code>reject</code></a></p>

                              <div class="method-source-code" id="top-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1298</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">top</span>
  <span class="ruby-ivar">@stack</span>[<span class="ruby-value">-1</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ver" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ver</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns version string from <a href="OptionParser.html#method-i-program_name"><code>program_name</code></a>, version and release.</p>

                              <div class="method-source-code" id="ver-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1279</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ver</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> = <span class="ruby-identifier">version</span>
    <span class="ruby-identifier">str</span> = <span class="ruby-node">+&quot;#{program_name} #{[v].join(&#39;.&#39;)}&quot;</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; (#{v})&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> = <span class="ruby-identifier">release</span>
    <span class="ruby-identifier">str</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-version" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">version</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="OptionParser.html#Version"><code>Version</code></a></p>

                              <div class="method-source-code" id="version-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1265</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">version</span>
  (<span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@version</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@version</span>) <span class="ruby-operator">||</span> (<span class="ruby-keyword">defined?</span>(<span class="ruby-operator">::</span><span class="ruby-constant">Version</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">::</span><span class="ruby-constant">Version</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-warn" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">warn</span><span
                                class="method-args">(mesg = $!)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="warn-source">
            <pre><span class="ruby-comment"># File optparse.rb, line 1287</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">warn</span>(<span class="ruby-identifier">mesg</span> = <span class="ruby-identifier">$!</span>)
  <span class="ruby-keyword">super</span>(<span class="ruby-node">&quot;#{program_name}: #{mesg}&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

